package com.ds.infra.mq.example.other;


import com.ds.infra.mq.core.api.MQProducer;
import com.ds.infra.mq.core.api.Producer;

public class ProducerExample {
    public static void main(String[] args) throws Exception {
        Producer producer = new MQProducer("localhost", 9092, "test-producer");
        ((MQProducer) producer).connect();

        String topic = "test-topic";
        int partition = 0;

        for (int i = 0; i < 10; i++) {
            String message = "Message-" + i;
            // 明确指定主题和分区
            producer.send(topic, partition, message.getBytes());
            System.out.println("Sent to " + topic + ":" + partition + " - " + message);
            Thread.sleep(1000);
        }

        producer.close();
    }
}
